package com.pxene.dmp.common;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

public class DecryptUtils {
    public static final char[] DATA_CV_0 = { '0', 'f', 'p' };
    public static final char[] DATA_CV_1 = { '1', 'b', 'z' };
    public static final char[] DATA_CV_2 = { '2', 's', 'a' };
    public static final char[] DATA_CV_3 = { '3', 'h', 'e' };
    public static final char[] DATA_CV_4 = { '4', 'd', 'k' };
    public static final char[] DATA_CV_5 = { '5', 'v', 'l' };
    public static final char[] DATA_CV_6 = { '6', 't', 'n' };
    public static final char[] DATA_CV_7 = { '7', 'c', 'u' };
    public static final char[] DATA_CV_8 = { '8', 'g', 'w' };
    public static final char[] DATA_CV_9 = { '9', 'y', 'j' };
    //{ 'i', 'm', 'r', 'o', 'q', 'x' };
    private static final Map<Character, Character> signs = new HashMap<Character, Character>();
	static {
		signs.put('o', '.');
		signs.put('x', ',');
	}
    
    public static String decryptStr(String str) {
		String res = "";
		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);
			if (ArrayIndexOf(DATA_CV_0, c) >= 0) {
				res += 0;
			} else if (ArrayIndexOf(DATA_CV_1, c) >= 0) {
				res += 1;
			} else if (ArrayIndexOf(DATA_CV_2, c) >= 0) {
				res += 2;
			} else if (ArrayIndexOf(DATA_CV_3, c) >= 0) {
				res += 3;
			} else if (ArrayIndexOf(DATA_CV_4, c) >= 0) {
				res += 4;
			} else if (ArrayIndexOf(DATA_CV_5, c) >= 0) {
				res += 5;
			} else if (ArrayIndexOf(DATA_CV_6, c) >= 0) {
				res += 6;
			} else if (ArrayIndexOf(DATA_CV_7, c) >= 0) {
				res += 7;
			} else if (ArrayIndexOf(DATA_CV_8, c) >= 0) {
				res += 8;
			} else if (ArrayIndexOf(DATA_CV_9, c) >= 0) {
				res += 9;
			} else {
				res += signs.get(c);
			}
		}
		return res;
	}
    
    public static int ArrayIndexOf(char[] cs, char c) {
    	for (int i = 0; i < cs.length; i ++) {
    		if (c == cs[i]) {
    			return i;
    		}
    	}
    	return -1;
    }
    
    public static void main(String[] args) {
		String str="#963f#767e#5ddd";
		System.out.println(decryptStr(str));
	}
}
